package com.chookss.home.gallery.adapter;

import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chookss.R;
import com.chookss.base.BaseViewHolderEx;
import com.chookss.home.entity.GallerySearchEntity;
import com.chookss.home.gallery.GallerySearchPicListActivity;
import com.chookss.tools.Utils;
import com.chookss.view.DrawableTextView;

import java.util.List;

import io.reactivex.annotations.Nullable;

public class GallerySearchListAddressAdapter extends BaseQuickAdapter<GallerySearchEntity.CityListBean.ListBean, BaseViewHolderEx> {
    private Activity context;
    private String searchKeyWord, title, startTime, endTime, provides,orgCodes, catalogCodes, tagCodes, provinces, citys, fileTypes;

    public GallerySearchListAddressAdapter(int layoutResId, Activity context, @Nullable List<GallerySearchEntity.CityListBean.ListBean> data) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolderEx helper, GallerySearchEntity.CityListBean.ListBean item) {
        TextView tvTitle = helper.getView(R.id.tvAddressName);
        DrawableTextView tvMore = helper.getView(R.id.tvAddressMore);
        tvTitle.setText(item.getName());
        tvMore.setText(Utils.changeNumber(item.getImageNum()) + "");
        helper.getItemView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, GallerySearchPicListActivity.class);
                intent.putExtra("searchType", 1);
                intent.putExtra("citys", item.getName());
                intent.putExtra("searchKeyWord", "");
                intent.putExtra("title", tvTitle.getText().toString());
                intent.putExtra("startTime", startTime);
                intent.putExtra("endTime", endTime);
                intent.putExtra("provides", provides);
                intent.putExtra("orgCodes", orgCodes);
                intent.putExtra("catalogCodes", catalogCodes);
                intent.putExtra("tagCodes", tagCodes);
                intent.putExtra("provinces", "");
                intent.putExtra("fileTypes", fileTypes);
                context.startActivity(intent);
            }
        });
    }

    public void setSearchData(String searchKeyWord, String title, String startTime, String endTime, String provides,String orgCodes, String catalogCodes, String tagCodes, String provinces, String citys, String fileTypes) {
        this.searchKeyWord = searchKeyWord;
        this.title = title;
        this.startTime = startTime;
        this.endTime = endTime;
        this.provides = provides;
        this.orgCodes = orgCodes;
        this.catalogCodes = catalogCodes;
        this.tagCodes = tagCodes;
        this.provinces = provinces;
        this.citys = citys;
        this.fileTypes = fileTypes;
    }
}
